home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / v cisle / htttrack / httrack-3.41-3.exe / {app} / src / htsglobal.h < prev    next >
C/C++ Source or Header  |  2007-06-15  |  10KB  |  514 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: Global #define file                                    */
  34. /* Author: Xavier Roche                                         */
  35. /* ------------------------------------------------------------ */
  36.  
  37. // Fichier rΘunissant l'ensemble des defines
  38.  
  39. #ifndef HTTRACK_GLOBAL_DEFH
  40. #define HTTRACK_GLOBAL_DEFH
  41.  
  42. // Version
  43. #define HTTRACK_VERSION      "3.41-3"
  44. #define HTTRACK_VERSIONID    "3.41.22"
  45. #define HTTRACK_AFF_VERSION  "3.x"
  46. #define HTTRACK_LIB_VERSION  "2.0"
  47.  
  48. #ifndef HTS_NOINCLUDES
  49. #ifndef _WIN32_WCE
  50. #include <stdio.h>
  51. #include <stdlib.h>
  52. #else
  53. #include <stdio.h>
  54. #include <stdlib.h>
  55. #ifdef HTS_CECOMPAT
  56. #include "cecompat.h"
  57. #else
  58. #include "celib.h"
  59. #endif
  60. #endif
  61. #endif
  62.  
  63. // DΘfinition plate-forme
  64. #include "htsconfig.h"
  65.  
  66. // WIN32 types
  67. #ifdef _WIN32
  68. #ifndef SIZEOF_LONG
  69. #define SIZEOF_LONG 4
  70. #define SIZEOF_LONG_LONG 8
  71. #endif
  72. #endif
  73.  
  74.  
  75. // config.h
  76. #ifdef _WIN32
  77.  
  78. // WIN32
  79. #ifndef _WIN32_WCE
  80.  
  81. #define HAVE_SYS_STAT_H 1
  82. #define HAVE_SYS_TYPES_H 1
  83. #define HAVE_SYS_STAT_H 1
  84. #ifndef DLLIB
  85. #define DLLIB 1
  86. #endif
  87. #ifndef HTS_INET6
  88. #define HTS_INET6 1
  89. #endif
  90. #ifndef S_ISREG
  91. #define S_ISREG(m) ((m) & _S_IFREG)
  92. #define S_ISDIR(m) ((m) & _S_IFDIR)
  93. #endif
  94.  
  95. #else
  96.  
  97. // Win32CE
  98. //#pragma runtime_checks( "s", restore )
  99. #define HTS_SPARE_MEMORY 1
  100. #define HTS_ALIGN 8
  101. #define BIGSTK static
  102. #undef DLLIB   // LoadLibrary(libssl) crashes
  103. #define NOSTRDEBUG 1
  104. #undef HTS_MAKE_KEYWORD_INDEX
  105. #ifdef HTS_CECOMPAT
  106. #define HTS_DO_NOT_USE_FTIME 1
  107. #undef HAVE_SYS_STAT_H
  108. #undef HAVE_SYS_TYPES_H
  109. #else
  110. #undef HTS_DO_NOT_USE_FTIME
  111. #define HAVE_SYS_STAT_H 1
  112. #define HAVE_SYS_TYPES_H 1
  113. #endif
  114.  
  115. #define HTS_DLOPEN 0
  116. #undef HTS_INET6
  117. #ifndef S_ISREG
  118. #define S_ISREG(m) ((m) & _S_IFREG)
  119.  
  120. #endif
  121.  
  122. #endif
  123.  
  124. #else
  125.  
  126. #include "config.h"
  127.  
  128. #ifndef FTIME
  129. #define HTS_DO_NOT_USE_FTIME
  130. #endif
  131.  
  132. #ifndef SETUID
  133. #define HTS_DO_NOT_USE_UID
  134. #endif
  135.  
  136. #ifndef HTS_LONGLONG
  137. #ifdef SIZEOF_LONG_LONG
  138. #if SIZEOF_LONG_LONG==8
  139. #define HTS_LONGLONG 1
  140. #endif
  141. #endif
  142.  
  143. #ifndef HTS_LONGLONG
  144. #ifdef __sun
  145. #define HTS_LONGLONG 0
  146. #endif
  147. #ifdef __osf__
  148. #define HTS_LONGLONG 0
  149. #endif
  150. #ifdef __linux
  151. #define HTS_LONGLONG 1
  152. #endif
  153. #ifdef _WIN32
  154. #define HTS_LONGLONG 1
  155. #endif
  156. #endif
  157. #endif
  158.  
  159. #ifdef DLLIB
  160. #define HTS_DLOPEN 1
  161. #else
  162. #define HTS_DLOPEN 0
  163. #endif
  164.  
  165. #endif
  166.  
  167. // don't spare memory usage by default
  168. #ifndef HTS_SPARE_MEMORY
  169. #define HTS_SPARE_MEMORY 0
  170. #endif
  171.  
  172. #ifndef BIGSTK 
  173. #define BIGSTK
  174. #endif
  175.  
  176. // compatibilitΘ DOS
  177. #ifdef _WIN32
  178. #define HTS_DOSNAME 1
  179. #else
  180. #define HTS_DOSNAME 0
  181. #endif
  182.  
  183. // utiliser zlib?
  184. #ifndef HTS_USEZLIB
  185. // autoload
  186. #define HTS_USEZLIB 1
  187. #endif
  188.  
  189. #ifndef HTS_INET6
  190. #define HTS_INET6 0
  191. #endif
  192.  
  193. // utiliser openssl?
  194. #ifndef HTS_USEOPENSSL
  195. // autoload
  196. #define HTS_USEOPENSSL 1
  197. #endif
  198.  
  199. // utiliser mms://?
  200. #ifndef HTS_USEMMS
  201. #define HTS_USEMMS 1
  202. #endif
  203.  
  204. #ifndef HTS_DLOPEN
  205. #define HTS_DLOPEN 1
  206. #endif
  207.  
  208. #ifndef HTS_USESWF
  209. #define HTS_USESWF 1
  210. #endif
  211.  
  212. #ifdef _WIN32
  213. #else
  214. #define __cdecl
  215. #endif
  216.  
  217. /* rc file */
  218. #ifdef _WIN32
  219. #define HTS_HTTRACKRC "httrackrc"
  220. #else
  221.  
  222. #ifndef HTS_ETCPATH
  223. #define HTS_ETCPATH "/etc"
  224. #endif
  225. #ifndef HTS_BINPATH
  226. #define HTS_BINPATH "/usr/bin"
  227. #endif
  228. #ifndef HTS_LIBPATH
  229. #define HTS_LIBPATH "/usr/lib"
  230. #endif
  231. #ifndef HTS_PREFIX
  232. #define HTS_PREFIX "/usr"
  233. #endif
  234.  
  235. #define HTS_HTTRACKRC ".httrackrc"
  236. #define HTS_HTTRACKCNF HTS_ETCPATH"/httrack.conf"
  237.  
  238. #ifdef DATADIR
  239. #define HTS_HTTRACKDIR DATADIR"/httrack/"
  240. #else
  241. #define HTS_HTTRACKDIR HTS_PREFIX"/share/httrack/"
  242. #endif
  243.  
  244. #endif
  245.  
  246. #if HTS_SPARE_MEMORY==0
  247. /* Gestion des tables de hashage */
  248. #define HTS_HASH_SIZE 20147
  249. /* Taille max d'une URL */
  250. #define HTS_URLMAXSIZE 1024
  251. /* Taille max ligne de commande (>=HTS_URLMAXSIZE*2) */
  252. #define HTS_CDLMAXSIZE 1024
  253. #else
  254. /* Gestion des tables de hashage */
  255. #define HTS_HASH_SIZE 1023
  256. /* Taille max d'une URL */
  257. #define HTS_URLMAXSIZE 256
  258. /* Taille max ligne de commande (>=HTS_URLMAXSIZE*2) */
  259. #define HTS_CDLMAXSIZE 1024
  260. #endif
  261.  
  262. /* Copyright (C) Xavier Roche and other contributors */
  263. #define HTTRACK_AFF_AUTHORS "[XR&CO'2007]"
  264. #define HTS_DEFAULT_FOOTER "<!-- Mirrored from %s%s by HTTrack Website Copier/"HTTRACK_AFF_VERSION" "HTTRACK_AFF_AUTHORS", %s -->"
  265. #define HTTRACK_WEB "http://www.httrack.com"
  266. #define HTS_UPDATE_WEBSITE "http://www.httrack.com/update.php3?Product=HTTrack&Version="HTTRACK_VERSIONID"&VersionStr="HTTRACK_VERSION"&Platform=%d&Language=%s"
  267.  
  268. #define H_CRLF "\x0d\x0a"
  269. #define CRLF   "\x0d\x0a"
  270. #ifdef _WIN32
  271. #define LF "\x0d\x0a"
  272. #else
  273. #define LF "\x0a"
  274. #endif
  275.  
  276. /* Θquivaut α "paramΦtre vide", par exemple -F (none) */
  277. #define HTS_NOPARAM "(none)"
  278. #define HTS_NOPARAM2 "\"(none)\""
  279.  
  280. /* maximum et minimum */
  281. #define maximum(A,B) ( (A) > (B) ? (A) : (B) )
  282. #define minimum(A,B) ( (A) < (B) ? (A) : (B) )
  283.  
  284. /* chaine vide? */
  285. #define strnotempty(A) (((A)[0]!='\0') ? 1 : 0)
  286.  
  287. /* optimisation inline si possible */
  288. #ifdef __cplusplus
  289. #define HTS_INLINE inline
  290. #else
  291. #define HTS_INLINE
  292. #endif
  293.  
  294. #ifdef _WIN32
  295. #ifdef LIBHTTRACK_EXPORTS
  296. #define HTSEXT_API __declspec(dllexport)
  297. #else
  298. #define HTSEXT_API __declspec(dllimport)
  299. #endif
  300. #else
  301. #define HTSEXT_API 
  302. #endif
  303.  
  304. #ifndef HTS_LONGLONG
  305. #ifdef HTS_NO_64_BIT
  306. #define HTS_LONGLONG 0
  307. #else
  308. #define HTS_LONGLONG 1
  309. #endif
  310. #endif
  311.  
  312. // long long int? (or int)
  313. // (and int cast for system functions like malloc() )
  314.  
  315. #if HTS_LONGLONG
  316. #ifdef LLINT_FORMAT
  317.   typedef LLINT_TYPE LLint;
  318.   typedef LLINT_TYPE TStamp;
  319.   #define LLintP LLINT_FORMAT
  320. #else
  321.  
  322. #ifdef _WIN32
  323.  typedef __int64 LLint;
  324.  typedef __int64 TStamp;
  325.  #define LLintP "%I64d"
  326. #elif (defined(__x86_64__) || defined(_LP64) || defined(__64BIT__))
  327.   typedef unsigned long int LLint;
  328.   typedef unsigned long int TStamp;
  329.   #define LLintP "%ld"
  330. #else
  331.   typedef long long int LLint;
  332.   typedef long long int TStamp;
  333.   #define LLintP "%lld"
  334. #endif
  335.  
  336. #endif  /* HTS_LONGLONG */
  337.  
  338. #else
  339.  typedef int LLint;
  340.  #define LLintP "%d"
  341.  typedef double TStamp;
  342. #endif
  343.  
  344. #ifdef LFS_FLAG
  345. typedef LLint INTsys;
  346. #define INTsysP LLintP
  347. #ifdef __linux
  348. #define HTS_FSEEKO
  349. #endif
  350. #else
  351. typedef int INTsys;
  352. #define INTsysP "%d"
  353. #endif
  354.  
  355. #ifdef _WIN32
  356. #if defined(_WIN64)
  357. typedef unsigned __int64 T_SOC;
  358. #else
  359. typedef unsigned __int32 T_SOC;
  360. #endif
  361. #else
  362. typedef int T_SOC;
  363. #endif
  364.  
  365. /* Default alignement */
  366. #ifndef HTS_ALIGN
  367. #define HTS_ALIGN (sizeof(void*))
  368. #endif
  369.  
  370. /* IPV4, IPV6 and various unified structures */
  371. #define HTS_MAXADDRLEN 64
  372.  
  373. #ifdef _WIN32
  374. #else
  375. #define __cdecl 
  376. #endif
  377.  
  378. /* mode pour mkdir ET chmod (accΦs aux fichiers) */
  379. #define HTS_PROTECT_FOLDER (S_IRUSR|S_IWUSR|S_IXUSR)
  380. #if HTS_ACCESS
  381. #define HTS_ACCESS_FILE (S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
  382. #define HTS_ACCESS_FOLDER (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
  383. #else
  384. #define HTS_ACCESS_FILE (S_IRUSR|S_IWUSR)
  385. #define HTS_ACCESS_FOLDER (S_IRUSR|S_IWUSR|S_IXUSR)
  386. #endif
  387.  
  388. /* vΘrifier la dΘclaration des variables prΘprocesseur */
  389. #ifndef HTS_DOSNAME
  390. #error | HTS_DOSNAME Has not been defined.
  391. #error | Set it to 1 if you are under DOS, 0 under Unix.
  392. #error | Example: place this line in you source, before includes:
  393. #error | #define HTS_DOSNAME 0
  394. #error
  395. #error
  396. #endif
  397. #ifndef HTS_ACCESS
  398. /* Par dΘfaut, accΦs α tous les utilisateurs */
  399. #define HTS_ACCESS 1
  400. #endif
  401.  
  402. /* fflush sur stdout */
  403. #define io_flush { fflush(stdout); fflush(stdin); }
  404.  
  405.  
  406.  
  407. /* HTSLib */
  408.  
  409. // Cache DNS, accΘlΦre les rΘsolution d'adresses
  410. #define HTS_DNSCACHE 1
  411.  
  412. // ID d'une pseudo-socket locale pour les file://
  413. #define LOCAL_SOCKET_ID -500000
  414.  
  415. // taille de chaque buffer (10 sockets 650 ko)
  416. #if HTS_SPARE_MEMORY==0
  417. #define TAILLE_BUFFER 65536
  418. #else
  419. #define TAILLE_BUFFER 8192
  420. #endif
  421.  
  422. #ifdef HTS_DO_NOT_USE_PTHREAD
  423. #error needs threads support
  424. #endif
  425. #define USE_BEGINTHREAD 1
  426.  
  427. #ifdef _DEBUG
  428. // trace mallocs
  429. //#define HTS_TRACE_MALLOC
  430. #ifdef HTS_TRACE_MALLOC
  431. typedef unsigned long int t_htsboundary;
  432. #ifndef HTS_DEF_FWSTRUCT_mlink
  433. #define HTS_DEF_FWSTRUCT_mlink
  434. typedef struct mlink mlink;
  435. #endif
  436. struct mlink {
  437.   char* adr;
  438.   int len;
  439.   int id;
  440.   struct mlink* next;
  441. };
  442. static const t_htsboundary htsboundary = 0xDEADBEEF;
  443. #endif
  444. #endif
  445.  
  446. /* strxxx debugging */
  447. #ifndef NOSTRDEBUG
  448. #define STRDEBUG 1
  449. #endif
  450.  
  451.  
  452. /* ------------------------------------------------------------ */
  453. /* Debugging                                                    */
  454. /* ------------------------------------------------------------ */
  455.  
  456. // dΘbuggage types
  457. #define DEBUG_SHOWTYPES 0
  458. // backing debug
  459. #define BDEBUG 0
  460. // chunk receive
  461. #define CHUNKDEBUG 0
  462. // realloc links debug
  463. #define MDEBUG 0
  464. // cache debug
  465. #define DEBUGCA 0
  466. // DNS debug
  467. #define DEBUGDNS 0
  468. // savename debug
  469. #define DEBUG_SAVENAME 0
  470. // debug robots
  471. #define DEBUG_ROBOTS 0
  472. // debug hash
  473. #define DEBUG_HASH 0
  474. // VΘrification d'intΘgritΘ
  475. #define DEBUG_CHECKINT 0
  476. // nbr sockets debug
  477. #define NSDEBUG 0
  478.  
  479. // dΘbuggage HTSLib
  480. #define HDEBUG 0
  481. // surveillance de la connexion
  482. #define CNXDEBUG 0
  483. // debuggage cookies
  484. #define DEBUG_COOK 0
  485. // dΘbuggage hard..
  486. #define HTS_WIDE_DEBUG 0
  487. // debuggage deletehttp et cie
  488. #define HTS_DEBUG_CLOSESOCK 0
  489. // debug tracage mΘmoire
  490. #define MEMDEBUG 0
  491.  
  492. // htsmain
  493. #define DEBUG_STEPS 0
  494.  
  495.  
  496. // DΘbuggage de contr⌠le
  497. #if HTS_DEBUG_CLOSESOCK
  498. #define _HTS_WIDE 1
  499. #endif
  500. #if HTS_WIDE_DEBUG
  501. #define _HTS_WIDE 1
  502. #endif
  503. #if _HTS_WIDE
  504. extern FILE* DEBUG_fp;
  505. #define DEBUG_W(A)  { if (DEBUG_fp==NULL) DEBUG_fp=fopen("bug.out","wb"); fprintf(DEBUG_fp,":>"A); fflush(DEBUG_fp); }
  506. #undef _
  507. #define _ ,
  508. #endif
  509.  
  510.  
  511.  
  512. #endif
  513.  
  514.